<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .box {
        width: 500px;
        height: 500px;
        background-color: gainsboro;
        display: flex;
        /* 改变排列方式 默认横排, 竖排 */
        flex-direction: row;
        /* 主轴方向上 两端对齐 */
        justify-content: space-between;
        /* 交叉轴方向上 默认顶端对齐  现在是居中*/
        align-items: center;
        /* 子元素超出父容器是否换行 */
        flex-wrap: wrap;
        /* 换行了才有效果 */
        align-content: space-between;

    }

    .box5,
    .box6 {
        height: 100px;
        width: 500px;
        display: flex;
        justify-content: space-between;
    }

    .box1 {
        width: 100px;
        height: 100px;
        background-color: red;
    }

    .box2 {
        width: 100px;
        height: 100px;
        background-color: rgb(9, 216, 60);
    }

    .box3 {
        width: 100px;
        height: 100px;
        background-color: rgb(22, 47, 212);
    }

    .box4 {
        width: 100px;
        height: 100px;
        background-color: rgb(169, 18, 192);
    }
</style>

<body>
    <div class="box">
        <div class="box5">
            <div class="box1">1</div>
            <div class="box2">2</div>
        </div>
        <div class="box6">
            <div class="box3">3</div>
            <div class="box4">4</div>
        </div>

        <!-- <div class="box3">5</div>
        <div class="box3">6</div>
        <div class="box2">7</div>
        <div class="box3">8</div> -->
    </div>
</body>

</html>